﻿using Mbl.ParameterizedTest.AcceptanceTests.CalculatorTests;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using System;

namespace Mbl.ParameterizedTest.AcceptanceTests.GeneralExpectationTests
{
    [TestClass]
    public class PredicateTests
    {
        [TestMethod]
        [ExpectedFailedTestCases(2, 3)]
        public void Assertion_can_be_made_based_on_a_predicate_of_the_actual_output()
        {            
            ParameterizedTest
                .For<string>(s => s)
                .Given("asdf").Expect(actual => actual.EndsWith("df")).Because("It's an identity mapping")
                .Given("asdf").Expect(actual => actual.EndsWith("XYZ")).Because("It's wrong")
                .Given("asdf").Expect((string actual) => {throw new InvalidOperationException("Oups");}).Because("It's an exception")
                .Evaluate();
        }

        [TestMethod]
        [ExpectedFailedTestCases(2, 3)]
        public void Assertion_can_be_made_based_on_a_predicate_of_the_input()
        {
            ParameterizedTest
                .For<string>(s => s)
                .Given("asdf").Expect(input => input.In1).Because("It's an identity mapping")
                .Given("asdf").Expect(input => null).Because("It's wrong")                
                .Given("asdf").Expect(input => input.In1 + "_!").Because("It's wrong")
                .Evaluate();
        }
    }
}
